[storage/qmdb] fix panic in find_next when fetch_batch_size overflows MAX_LOCATION#3526
Open
0xAysh wants to merge 1 commit into
Open
[storage/qmdb] fix panic in find_next when fetch_batch_size overflows MAX_LOCATION#35260xAysh wants to merge 1 commit into
0xAysh wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #3526 +/- ##
==========================================
- Coverage 95.74% 95.74% -0.01%
==========================================
Files 438 438
Lines 157975 157975
Branches 3706 3706
==========================================
- Hits 151249 151248 -1
- Misses 5541 5542 +1
Partials 1185 1185
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2068
Problem
find_nextinqmdb/sync/gaps.rspanics when projecting the end location of an outstanding request:Location::checked_addreturnsNonewhen the result exceedsMAX_LOCATION(2^62 - 1). With astart_locnearMAX_LOCATIONand afetch_batch_sizelarge enough to overflow that bound,.unwrap()panics.fetch_batch_sizeiscaller-supplied config with no upper-bound validation relative to the target range, so this is reachable in normal sync invocations.
The same
.unwrap()pattern exists one line above forfetched_operationsoperation counts and is fixed for consistency.Fix
Replace both
.checked_add(...).unwrap()calls with.saturating_add(...), lamping atMAX_LOCATIONinstead of returningNone.end_locis only used to determine coverage within the range, andrange.end <= MAX_LOCATIONalways holds.